package com.tj.controller;

import com.tj.exception.BusinessException;
import com.tj.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {
    /**
     * 异常处理方法
     * @param ex
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result<String> doException(Exception ex) {
        System.out.println("exception show");
        return Result.error("exception");
    }

    @ExceptionHandler(SystemException.class)
    public Result<String> doSystemException(SystemException ex) {
        return Result.error("SystemException");
    }

    @ExceptionHandler(BusinessException.class)
    public Result<String> doBusinessException(BusinessException ex) {
        return Result.error("BusinessException");
    }
}
